﻿using System;
using System.Collections.Generic;
using System.Text;

using Aliyun.OSS.Common;

namespace Aliyun.OSS.Samples
{
    /// <summary>
    /// 返回值 详细信息
    /// 张睿 2017-10-30
    /// </summary>
    [Serializable]
    public class Result
    {
        #region 属性
        string status = "-1";
        /// <summary>
        /// 0:成功 其它：失败
        /// </summary>
        public string Status
        {
            get { return status; }
            internal set { status = value; }
        }

        string errorCode = string.Empty;
        /// <summary>
        /// The error code getter
        /// </summary>
        public string ErrorCode
        {
            get { return errorCode; }
            internal set { errorCode = value; }
        }


        string message = string.Empty;
        /// <summary>
        /// 消息
        /// </summary>
        public string Message
        {
            get { return message; }
            internal set { message = value; }
        }

        string requestId= string.Empty;
        /// <summary>
        /// The requestId getter
        /// </summary>
        public string RequestId
        {
            get { return requestId; }
            internal set { requestId = value; }
        }


        string hostId = string.Empty;
        /// <summary>
        /// Host ID getter
        /// </summary>
        public string HostId
        {
            get { return hostId; }
            internal set { hostId = value; }
        }

        #endregion 属性

        #region 方法

        /// <summary>
        /// 填充异常信息
        /// </summary>
        /// <param name="ex">异常</param>
        public void FillOssException(OssException ex)
        {
            this.ErrorCode = ex.ErrorCode;
            this.HostId = ex.HostId;
            this.Message = ex.Message;
            this.RequestId = ex.RequestId;
        }

        /// <summary>
        /// 获取简单Json
        /// </summary>
        /// <returns></returns>
        public string GetDefaultJsonStr()
        {
            return string.Format("{Status:'{0}',Message:'{1}'}", this.Status, this.Message);
        }

        #endregion 方法
    }
}
